package jk.fox.invocation.proxy;


import jk.fox.engine.RpcNodeDefinition;
import jk.fox.invocation.Invocation;

import java.lang.reflect.Proxy;

/**
 * @author cuichao
 * @Description: JdkProxyFactory
 * @Date: create in 2020/4/12 14:00
 */
public class JdkProxyFactory implements ProxyFactory {

    @Override
    public Object getProxy(RpcNodeDefinition definition, Invocation invocation) {
        RpcJdkProxy proxy = new RpcJdkProxy(invocation,definition);
        Object obj = Proxy.newProxyInstance(proxy.getClass().getClassLoader(), new Class[]{definition.getTarget()}, proxy);
        return obj;
    }

}
